document.getElementById("create").onclick=function(){
	var username=getQ().username
	var unit=getQ().unit
	window.open ("vehicle_edit.html?type=POST&username="+username+"&unit="+unit, "_blank", "height=900, width=500, top=160, left=200, toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
}


$.ajax({
	"url":"/vehicle/",
	"error":errorAjax,
	"beforeSend":start_load_pic,
	"complete":stop_load_pic,
	"data":{"username":getQ().username},
	"dataType":"jsonp",
	"success":function(data){
		if(responseCheck(data)){
			var tab=document.getElementById("tab")
			for(var i=0;i<data.content.length;i++){
				var tr=document.createElement("tr")

				var td=document.createElement("td")
				td.textContent=data.content[i].number
				tr.appendChild(td)

				var td=document.createElement("td")
				td.textContent=data.content[i].name
				tr.appendChild(td)

				var td=document.createElement("td")
				td.textContent=data.content[i].date
				tr.appendChild(td)

				var td=document.createElement("td")
				var b=document.createElement("button")
				b.className="btn btn-xs btn-danger"
				b.setAttribute("_id",data.content[i].id)
				b.textContent="删除"
				b.onclick=function(){
					//vehicellist_id
					var _id=this.getAttribute("_id")
					$.ajax({
						"error":errorAjax,
						"url":"/vehicle/",
						"complete":stop_load_pic,
						"beforeSend":start_load_pic,
						"type":"DELETE",
						"data":{"data":_id},
						"success":function(data){
							if(responseCheck(data)){
								alert("操作成功！")
								window.location.reload()
							}
						}
					})
				
				}
				td.appendChild(b)
				tr.appendChild(td)


				tab.appendChild(tr)
			}
		}
	}
})
